package com.m20studio.mop.activity;


import java.util.ArrayList;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;

import com.m20studio.mop.R;
import com.m20studio.mop.db.DBHelper;
import com.m20studio.mop.xml.XMLFeed;


public class Splash extends Activity{		
	
	private ImageView imageView1,imageView2,imageView3,imageView4,imageView5,imageView6,imageView7,imageView8,imageView9,imageView10,imageView11,imageView12,imageView13,imageView14,imageView15,imageView16,imageView17,imageView18,imageView19,imageView20;
	private DBHelper dbHelper;
	private ArrayList<XMLFeed> xmllists;
	/** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
    	super.onCreate(savedInstanceState);
        setContentView(R.layout.splash);
        
        imageView1 = (ImageView) findViewById(R.id.imageView1);
        imageView2 = (ImageView) findViewById(R.id.imageView2);
        imageView3 = (ImageView) findViewById(R.id.imageView3);
        imageView4 = (ImageView) findViewById(R.id.imageView4);
        imageView5 = (ImageView) findViewById(R.id.imageView5);
        imageView6 = (ImageView) findViewById(R.id.imageView6);
        imageView7 = (ImageView) findViewById(R.id.imageView7);
        imageView8 = (ImageView) findViewById(R.id.imageView8);
        imageView9 = (ImageView) findViewById(R.id.imageView9);
        imageView10 = (ImageView) findViewById(R.id.imageView10);
        imageView11 = (ImageView) findViewById(R.id.imageView11);
        imageView12 = (ImageView) findViewById(R.id.imageView12);
        imageView13 = (ImageView) findViewById(R.id.imageView13);
        imageView14 = (ImageView) findViewById(R.id.imageView14);
        imageView15 = (ImageView) findViewById(R.id.imageView15);
        imageView16 = (ImageView) findViewById(R.id.imageView16);
        imageView17 = (ImageView) findViewById(R.id.imageView17);
        imageView18 = (ImageView) findViewById(R.id.imageView18);
        imageView19 = (ImageView) findViewById(R.id.imageView19);
        imageView20 = (ImageView) findViewById(R.id.imageView20);
       
        xmllists = new ArrayList<XMLFeed>();
        dbHelper = new DBHelper(this);		
		xmllists = (ArrayList<XMLFeed>) dbHelper.getListData(0, 1);
        //4秒钟后跳转
        new Handler().postDelayed(new Runnable(){          	
			public void run() {        		
        		if (xmllists.isEmpty()){
        			Intent intent = new Intent(Splash.this, Help.class); 
            		Splash.this.startActivity(intent);
            		Splash.this.finish();
        		}else{
        			Intent intent = new Intent(Splash.this, ClassTZ.class); 
              		intent.putExtra("lmId", 0);
              		intent.putExtra("classId", 0);
            		Splash.this.startActivity(intent);
            		Splash.this.finish();       			
        		}
        		
        	}  
        }, 5000);
        new Handler().postDelayed(new Runnable(){  
        	public void run() {  
        		Animation a = AnimationUtils.loadAnimation(Splash.this, R.anim.splash);
        		imageView1.setVisibility(View.VISIBLE);
                imageView1.startAnimation(a);
        	}  
        }, 200);
        new Handler().postDelayed(new Runnable(){  
        	public void run() {  
        		Animation a = AnimationUtils.loadAnimation(Splash.this, R.anim.splash);
        		imageView2.setVisibility(View.VISIBLE);
                imageView2.startAnimation(a);
        	}  
        }, 400);
        new Handler().postDelayed(new Runnable(){  
        	public void run() {  
        		Animation a = AnimationUtils.loadAnimation(Splash.this, R.anim.splash);
        		imageView3.setVisibility(View.VISIBLE);
                imageView3.startAnimation(a);
        	}  
        }, 600);
        new Handler().postDelayed(new Runnable(){  
        	public void run() {  
        		Animation a = AnimationUtils.loadAnimation(Splash.this, R.anim.splash);
        		imageView4.setVisibility(View.VISIBLE);
                imageView4.startAnimation(a);
        	}  
        }, 800);
        new Handler().postDelayed(new Runnable(){  
        	public void run() {  
        		Animation a = AnimationUtils.loadAnimation(Splash.this, R.anim.splash);
        		imageView5.setVisibility(View.VISIBLE);
                imageView5.startAnimation(a);
        	}  
        }, 1000);
        new Handler().postDelayed(new Runnable(){  
        	public void run() {  
        		Animation a = AnimationUtils.loadAnimation(Splash.this, R.anim.splash);
        		imageView6.setVisibility(View.VISIBLE);
                imageView6.startAnimation(a);
        	}  
        }, 1200);
        new Handler().postDelayed(new Runnable(){  
        	public void run() {  
        		Animation a = AnimationUtils.loadAnimation(Splash.this, R.anim.splash);
        		imageView7.setVisibility(View.VISIBLE);
                imageView7.startAnimation(a);
        	}  
        }, 1400);
        new Handler().postDelayed(new Runnable(){  
        	public void run() {  
        		Animation a = AnimationUtils.loadAnimation(Splash.this, R.anim.splash);
        		imageView8.setVisibility(View.VISIBLE);
                imageView8.startAnimation(a);
        	}  
        }, 1600);
        new Handler().postDelayed(new Runnable(){  
        	public void run() {  
        		Animation a = AnimationUtils.loadAnimation(Splash.this, R.anim.splash);
        		imageView9.setVisibility(View.VISIBLE);
                imageView9.startAnimation(a);
        	}  
        }, 1800);
        new Handler().postDelayed(new Runnable(){  
        	public void run() {  
        		Animation a = AnimationUtils.loadAnimation(Splash.this, R.anim.splash);
        		imageView10.setVisibility(View.VISIBLE);
                imageView10.startAnimation(a);
        	}  
        }, 2000);
        new Handler().postDelayed(new Runnable(){  
        	public void run() {  
        		Animation a = AnimationUtils.loadAnimation(Splash.this, R.anim.splash);
        		imageView11.setVisibility(View.VISIBLE);
                imageView11.startAnimation(a);
        	}  
        }, 2200);
        new Handler().postDelayed(new Runnable(){  
        	public void run() {  
        		Animation a = AnimationUtils.loadAnimation(Splash.this, R.anim.splash);
        		imageView12.setVisibility(View.VISIBLE);
                imageView12.startAnimation(a);
        	}  
        }, 2400);
        new Handler().postDelayed(new Runnable(){  
        	public void run() {  
        		Animation a = AnimationUtils.loadAnimation(Splash.this, R.anim.splash);
        		imageView13.setVisibility(View.VISIBLE);
                imageView13.startAnimation(a);
        	}  
        }, 2600);
        new Handler().postDelayed(new Runnable(){  
        	public void run() {  
        		Animation a = AnimationUtils.loadAnimation(Splash.this, R.anim.splash);
        		imageView14.setVisibility(View.VISIBLE);
                imageView14.startAnimation(a);
        	}  
        }, 2800);
        new Handler().postDelayed(new Runnable(){  
        	public void run() {  
        		Animation a = AnimationUtils.loadAnimation(Splash.this, R.anim.splash);
        		imageView15.setVisibility(View.VISIBLE);
                imageView15.startAnimation(a);
        	}  
        }, 3000);
        new Handler().postDelayed(new Runnable(){  
        	public void run() {  
        		Animation a = AnimationUtils.loadAnimation(Splash.this, R.anim.splash);
        		imageView16.setVisibility(View.VISIBLE);
                imageView16.startAnimation(a);
        	}  
        }, 3200);
        new Handler().postDelayed(new Runnable(){  
        	public void run() {  
        		Animation a = AnimationUtils.loadAnimation(Splash.this, R.anim.splash);
        		imageView17.setVisibility(View.VISIBLE);
                imageView17.startAnimation(a);
        	}  
        }, 3400);
        new Handler().postDelayed(new Runnable(){  
        	public void run() {  
        		Animation a = AnimationUtils.loadAnimation(Splash.this, R.anim.splash);
        		imageView18.setVisibility(View.VISIBLE);
                imageView18.startAnimation(a);
        	}  
        }, 3600);
        new Handler().postDelayed(new Runnable(){  
        	public void run() {  
        		Animation a = AnimationUtils.loadAnimation(Splash.this, R.anim.splash);
        		imageView19.setVisibility(View.VISIBLE);
                imageView19.startAnimation(a);
        	}  
        }, 3800);
        new Handler().postDelayed(new Runnable(){  
        	public void run() {  
        		Animation a = AnimationUtils.loadAnimation(Splash.this, R.anim.splash);
        		imageView20.setVisibility(View.VISIBLE);
                imageView20.startAnimation(a);
        	}  
        }, 4000);
        
    }

}
        